package com.ruoyi.process.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.workflow.FormDTO;
import com.ruoyi.process.service.IFlowInstance;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * 显示流程实例
 */
@RestController
@RequestMapping("/workflow/flowInstance")
public class FlowInstanceController {
    @Autowired
    private IFlowInstance flowInstance;
    @Log(title = "提交审批", businessType = BusinessType.OTHER)
    @GetMapping(value = "/apprform")
    public synchronized AjaxResult apprform(FormDTO apprForm) {
        flowInstance.startFlow(apprForm);
        return AjaxResult.success();
    }
    @Operation(summary = "撤销流程")
    @PostMapping(value = "/revoke")
    public AjaxResult revoke(@RequestBody FormDTO params) {
        flowInstance.revoke(params);
        return AjaxResult.success();
    }
    /**
     * 删除自定义流程实例
     */
    @Log(title = "自定义流程实例", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        flowInstance.deleteFlowInstanceByIds(ids);
        return AjaxResult.success();
    }
}
